{% extends "tcms_base.html" %}
{% load static %}
{% block subtitle %}Add new case{% endblock %}

{% block extra_head %}
{{ form.media }}
{% endblock %}

{% block custom_stylesheet %}
{% endblock %}

{% block custom_javascript %}
<script type="text/javascript" src="{% static 'js/testplan_actions.js' %}"></script>
<script type="text/javascript" src="{% static 'js/testcase_actions.js' %}"></script>
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/core.js' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/SelectFilter2.js' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/SelectBox.js' %}"></script>
<script type="text/javascript">
Nitrate.Utils.after_page_load(Nitrate.TestCases.Create.on_load);
</script>
{% endblock %}

{% block contents %}
<!--add new case -->
<div id="content">
	<form action="{% url "testcases-new" %}{% if test_plan %}?from_plan={{ test_plan.plan_id }}{% endif %}" method="POST">
		{% if test_plan %}
		<input type="hidden" name="from_plan" value="{{ test_plan.plan_id }}" />
		{% endif %}
		<div id="newcase" class="Detailform border-1">
			<div id="id_create_case_process" class="submit" style="display: none">
				<img src="{% static 'images/loading/ajax-button.gif' %}" />
			</div>
			<fieldset class="no-border background-light-grey">
				<div class="editor-side">
					<div class="data_row">
						<label id="item_title" class="strong">Summary</label>
						<span id="form_title" class="name">{{ form.summary }}</span>
							<div class="errors">
								{{ form.summary.errors }}
							</div>
					</div>
					<div class="data_row">
						<label class="lab strong">Component</label>
						<div class="component_select">{{ form.component }}</div>
						<div class="errors">{{ form.component.errors }}</div>
					</div>
					<div class="data_row">
						<label class="lab strong">Category</label>
						{{ form.category }}
						<a href="{% url 'admin:testcases_category_add' %}" class="addlink" id="id_addt_product_casecategory" target="_blank">Add Category</a><span class="grey">After Add and Refresh page</span><span class="errors">{{ form.category.errors }}</span>
					</div>
				</div>
				<div class="editor-side">
					<div class="data_row">
						<label>Product </label>
						<div id="display_product">{{ form.product }}</div>
						<div id="errors">{{ form.product.errors }}</div>
					</div>
					<div class="data_row">
						<label>Automated</label>
						{{ form.is_automated }}
                        <div class="automatedlist">
						{{ form.is_automated_proposed }}
						{{ form.is_automated_proposed.label }}
						</div>
                        <div class="errors">
							{{ form.is_automated.errors }}
							{{ form.is_automated_proposed.errors }}
						</div>
					</div>
					<div class="data_row">
						<label >Requirement</label>
						{{ form.requirement }}
						{{ form.requirement.errors }}
					</div>
					<div class="data_row">
						<label >Script</label>
						{{ form.script }}
						<div class="errors">{{ form.script.errors }}</div>
					</div>
                    <div class="data_row">
						<label >Alias</label>
						{{ form.alias }}
						<div class="errors">{{ form.alias.errors }}</div>
					</div>
					<div class="data_row">
						<label >Default Tester:</label>
						{{ form.default_tester }}<div class="errors">{{ form.default_tester.errors }}</div>
					</div>
					
					<div class="data_row">
						<label>Priority</label>
						{{ form.priority }}<div class="errors">{{ form.priority.errors }}</div>
					</div>
                    <div class="data_row">
						<label>Arguments</label>
						{{ form.arguments }}<div class="errors">{{ form.arguments.errors }}</div>
					</div>
                    <div class="data_row">
                        <label>Reference Link</label>
                        {{ form.extra_link }}<div class="errors">{{ form.extra_link.errors }}</div>
                    </div>

                    <div class="data_row">
						<label>Notes</label>
						{{ form.notes }}<div class="errors">{{ form.notes.errors }}</div>
					</div>
				</div>
			</fieldset>
			<fieldset class="no-border background-light-grey">
				<div class="editor-side">
					<div class="data_row">
						<h4 >Setup</h4>
						<div class="form">{{ form.setup }}</div>
						<div class="errors">{{ form.setup.errors }}</div>
					</div>
					<div class="data_row">
						<h4>Actions</h4>
						<div class="form">{{ form.action }}</div>
						<div class="errors">{{ form.action.errors }}</div>
					</div>
				</div>
				<div class="editor-side">

					<div class="data_row">
						<h4>Breakdown</h4>
						<div class="form">{{ form.breakdown }}</div>
						<div class="errors">{{ form.breakdown.errors }}</div>
					</div>
					<div class="data_row">
						<h4>Expected Results</h4>
						<div class="form">{{ form.effect }}</div>
						<div class="errors">{{ form.effect.errors }}</div>
					</div>
				</div>
			</fieldset>
			<div id="submit" class="submit-row">
				
				<input type="submit" value="Save" />
				<input type="submit" name="_continue" value="Save and continue editing" />
				{% if test_plan %}
				<input type="submit" name="_addanother" value="Save and add another" />
				<input type="submit" name="_returntoplan" value="Save and return to plan" />
				<input type="button" value="Cancel" class="js-plan-cancel" data-param="{% url 'test_plan_url_short' test_plan.pk %}" />
				{% else %}
				<input type="button" value="cancel" class="js-case-cancel" >
				{% endif %}
			</div>
		</div>
	</form>
</div>
{% endblock %}
